package com.interfaces.module.wx.controller;

import com.interfaces.config.RedisCache;
import com.interfaces.util.Result;
import com.interfaces.wx.WechatMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/wxinit")
public class WxController {
    @Autowired
    private RedisCache cache;
    //https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi
    @RequestMapping("/config")
    public Result config(String url){
        try{
            WechatMsg wechatMsg=new WechatMsg();
            Map map=wechatMsg.GET_JSAPI_TICKET(url,cache);
            return Result.SUCCESS(map);
        }catch (Exception e){
            return Result.ERROR(e.getMessage());
        }
    }
}
